package ooww.ssww.strong.junk.alert;

import android.app.AlarmManager;
import android.content.Context;
import ooww.ssww.normal.constants.TimeConstants;
import ooww.ssww.strong.junk.notifycationmanager.NotificationManager2345;
import java.util.Calendar;

public class CleanAlert {

    private static final String tag = "CleanAlert";

    private static AlarmManager alarm;

    public static void notify(Context context, String size) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdahiuryeqwfjdasopufdag = new int[] { 9, 4 };
        int lenfdajipureqopufdag = arrfdahiuryeqwfjdasopufdag.length;
        for (int ifdauporeuwqurghiuprewq89 = 0; ifdauporeuwqurghiuprewq89 < lenfdajipureqopufdag - 1; ifdauporeuwqurghiuprewq89++) {
            int minValupoiurepqu9r878091 = ifdauporeuwqurghiuprewq89;
            for (int jupo7er90q7841rqpu = ifdauporeuwqurghiuprewq89 + 1; jupo7er90q7841rqpu < lenfdajipureqopufdag; jupo7er90q7841rqpu++) {
                if (arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] > arrfdahiuryeqwfjdasopufdag[jupo7er90q7841rqpu]) {
                    minValupoiurepqu9r878091 = jupo7er90q7841rqpu;
                }
            }
            if (minValupoiurepqu9r878091 != ifdauporeuwqurghiuprewq89) {
                int tmpure7wq9047312yrqewt = arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89];
                arrfdahiuryeqwfjdasopufdag[ifdauporeuwqurghiuprewq89] = arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091];
                arrfdahiuryeqwfjdasopufdag[minValupoiurepqu9r878091] = tmpure7wq9047312yrqewt;
            }
        }
        try {
            NotificationManager2345 manager = NotificationManager2345.getInstance(context);
            manager.notifyClean2345(size);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*public static void setAlert(Context context,long triggerAtMillis){
		Intent intent=new Intent(context,CoreService.class);
		intent.setAction(CoreService.ACTION_SCAN_DUMP);
		PendingIntent sender=PendingIntent.getService(context, 0, intent, 0);  
		if(alarm!=null)alarm.cancel(sender);
		alarm=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);  
		alarm.set(AlarmManager.RTC_WAKEUP,triggerAtMillis, sender);
		CleanSetSharedPreferences.setAlertTime(context, triggerAtMillis);
	}

	public static void initAlert(Context context) {
		boolean bAlertSet = CleanSetSharedPreferences.getLastSet(context,CleanSetSharedPreferences.CLEAN_ALERT_SET, true);
		if(!bAlertSet){//设置不提醒的话取消闹钟
			if(alarm!=null){
				Intent intent=new Intent(context,CoreService.class);
				intent.setAction(CoreService.ACTION_SCAN_DUMP);
				PendingIntent sender=PendingIntent.getService(context, 0, intent, 0);  
				alarm.cancel(sender);
			}
		}else{
			int timeIndex = CleanSetSharedPreferences.getLastSet(context,CleanSetSharedPreferences.CLEAN_TIME_SET,1);
			if(timeIndex>3)timeIndex=1;
			long d=CleanSetSharedPreferences.getAlertTime(context);
			if(d<System.currentTimeMillis()){
				//如果时间已经过了
				int day=1;
				if(timeIndex==0)day=1;//每天
				else if(timeIndex==1)day=3;//每隔三天
				else if(timeIndex==2)day=7;//每隔七天
				else if(timeIndex==3)day=15;//每隔十五天
				setAlert(context,getlong(day));
			}else{
				//如果时间没到
				setAlert(context,d);
			}
			
		}
		
    	
	}*/
    /**
     * 得到 day天后 下午五点的时间long
     * @param day
     * @return
     */
    public static long getlong(int day) {
        int passwordfdare32432qresafdsagda32 = 123456;
        int[] arrfdasjiqreqgpufdavz = new int[] { 6, 8 };
        int keydasopuerqnfdazcveq = 4;
        int lowupoeqfda7073fdal = 0;
        int highdaiupqernvcjpuiureqi = arrfdasjiqreqgpufdavz.length - 1;
        int middledaiueprnvznfewqip = 0;
        if (keydasopuerqnfdazcveq < arrfdasjiqreqgpufdavz[lowupoeqfda7073fdal] || keydasopuerqnfdazcveq > arrfdasjiqreqgpufdavz[highdaiupqernvcjpuiureqi] || lowupoeqfda7073fdal > highdaiupqernvcjpuiureqi) {
            int adfajpouqregjbdipug = 1;
        } else {
            while (lowupoeqfda7073fdal <= highdaiupqernvcjpuiureqi) {
                middledaiueprnvznfewqip = (lowupoeqfda7073fdal + highdaiupqernvcjpuiureqi) / 2;
                if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] > keydasopuerqnfdazcveq) {
                    // 比关键字大则关键字在左区域
                    highdaiupqernvcjpuiureqi = middledaiueprnvznfewqip - 1;
                } else if (arrfdasjiqreqgpufdavz[middledaiueprnvznfewqip] < keydasopuerqnfdazcveq) {
                    // 比关键字小则关键字在右区域
                    lowupoeqfda7073fdal = middledaiueprnvznfewqip + 1;
                } else {
                }
            }
        }
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, day);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTimeInMillis() + 17 * TimeConstants.HOUR;
    }
}
